package com.yc.bbs.controller;

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import com.yc.bbs.entity.Result;
import com.yc.bbs.service.BizException;

@Component
@RestControllerAdvice
public class ExHandler {
	
	@ExceptionHandler(BizException.class)
	public Result handleBizException(BizException e) {
		return new Result(0,e.getMessage(), e.getData());
	}
	
	@ExceptionHandler(Exception.class)
	public Result handleException(Exception e) {
		e.printStackTrace();
		// 后台通知管理员 Or 客服处理问题（邮件，短信。。。）
		return new Result(0,"业务繁忙，稍后再试",null);
	}

}
